home *** CD-ROM | disk | FTP | other *** search
/ TeX 1995 July / TeX CD-ROM July 1995 (Disc 1)(Walnut Creek)(1995).ISO / macros / inrstex / inrsinputs / dvialw.ps < prev    next >
Text File  |  1991-09-05  |  9KB  |  310 lines

  1. % removed mote test (mjf)
  2. % <BEEBE.TEX.DVI>DVIALW.PS.17, 18-Sep-87 17:48:04, Edit by BEEBE
  3. % Add test for note paper and if unknown, use letter paper instead.
  4. % Non-Apple PostScript implementations do not know about note paper
  5. % but its use on the Apple LaserWriter gains 92K of virtual memory
  6. % <BEEBE.TEX.DVI>DVIALW.PS.16, 18-Sep-87 15:50:52, Edit by BEEBE
  7. % Modify coordinate computations to remove round-off errors
  8. % in landscape mode, and correct landscape page origin
  9. % <BEEBE.TEX.DVI>DVIALW.PS.14, 22-Jun-87 09:55:05, Edit by BEEBE
  10. % Add missing "0 900 translate Mtrx currentmatrix pop" to /LEGAL
  11. % <BEEBE.TEX.DVI>DVIALW.PS.13,  7-Jan-87 17:38:51, Edit by BEEBE
  12. % Add translate command to BOP so that (0,0) really corresponds to
  13. % the top left physical page corner.  The standard LaTeX file 
  14. % TESTPAGE.TEX can be used for this calibration; it might be sensitive
  15. % to the particular printer used.    
  16. % <BEEBE.TEX.DVI.NEW>DVIALW.PS.12, 10-Dec-86 17:24:50, Edit by BEEBE
  17. % Fix off-by-one error in definition of /B; to draw a box N pixels
  18. % wide, microscopic examination of output shows that the box width
  19. % must be N-1, not N, pixels; the boundary counts in the filling.                
  20. % <BEEBE.TEX.DVI.NEW>DVIALW.PS.9, 28-Nov-86 19:00:52, Edit by BEEBE
  21. % Change definition of EOP to use #copies and showpage
  22. % instead of {copypage} repeat erasepage
  23. % <BEEBE.TEX.DVI.NEW>DVIALW.PS.7, 16-Oct-86 13:09:36, Edit by BEEBE
  24. % Following Macintosh LaserWriter md dictionary, change most
  25. % def's to bdf's (bind def); this is claimed to speed up
  26. % operator access
  27. % <BEEBE.TEX.DVI.NEW>DVIALW.PS.5, 16-Oct-86 12:01:12, Edit by BEEBE
  28. % Change CTL-L to caret-L in comment
  29. % <BEEBE.TEX.DVI.NEW>DVIALW.PS.3, 13-Jun-86 10:48:39, Edit by BEEBE
  30. % Fix definition of NOTE, make it default in BOJ macro to try to reduce
  31. % incidence of VM errors
  32. % ----------------------------------------------------------------------
  33. % DVIALW PostScript macro definitions (keep in alphabetical order).  For
  34. % readability, these  are  heavily  commented,  but  we  adhere  to  the
  35. % convention that  percent is  used  ONLY to  mark  the beginning  of  a
  36. % comment (NEVER  occurs  inside a  PostScript  string), and  lines  are
  37. % limited to 80 characters.  That way, DVIALW can read these definitions
  38. % from a  file and  discard  comments and  trailing white  space  before
  39. % transmission to  the  PostScript output  file.   In the  interests  of
  40. % compactness, macros which  receive any significant  degree of use  are
  41. % given single letter names -- PostScript is already much too verbose.
  42. %
  43. % Coordinates are assumed to  be in pixels  (Resolution per inch).   The
  44. % page origin follows the  PostScript convention of  being in the  lower
  45. % left corner, y positive upwards along  the longer side of the page,  x
  46. % positive  to  the  right.   Letter  and  legal  sizes  are   therefore
  47. % equivalent as far as PostScript is concerned, but y coordinates can be
  48. % bigger in legal size.  In landscape mode, the page is rotated to place
  49. % the origin in  the upper left  corner, x positive  downward along  the
  50. % longer side of  the page, y  positive to the  right.  That way,  pages
  51. % eject from  the printer  upright when  viewed from  the front  of  the
  52. % printer.
  53. %
  54. % Document format is something like this:
  55. %
  56. %    %!PS-Adobe-1.0
  57. %    %%Dimensions: 0 0 612 792
  58. %    %%Title: DVIALW  -o1 -s300 foo12
  59. %    %%CreationDate: Sat Mar  8 10:52:52 1986
  60. %    %%Creator: BEEBE and [TeX82 DVI Translator Version 2.03b...]
  61. %    %%Pages: (atend)
  62. %    %%BugHistory: Incorporates save/restore and font reloading...
  63. %    %%BugHistory: Incorporates Allan Hetzel's 31-Oct-85 DARPA...
  64. %    %%EndComments
  65. %    %%EndProlog
  66. %    %%Page: 0 1
  67. %    TeXdict begin
  68. %    BOJ
  69. %    BOP
  70. %    ...
  71. %     1 EOP
  72. %    ^LBOP
  73. %    ...
  74. %     1 EOP
  75. %    ^LBOP
  76. %    ...
  77. %     1 EOP
  78. %    ^LEOJ
  79. %    %%Trailer
  80. %    %%Pages: 7
  81. %    %%PageTable:  0 1 3434
  82. %    ^D
  83. %
  84. % One formfeed is output  for each printed page  copy, in order to  make
  85. % spooler page accounting simple.  The additional comments wrapping  the
  86. % BOJ ..  EOJ  sequence conform  to  Adobe PostScript  file  structuring
  87. % conventions, and the first line can be used by the spooler to identify
  88. % the file as containing PostScript.
  89. % ----------------------------------------------------------------------
  90.  
  91.  
  92. /TeXdict 200 dict def        % dictionary for these definitions
  93. TeXdict begin
  94.  
  95. % bdf -- bind def (for efficiency)
  96. % Usage -- just like def, but not on constant objects
  97. /bdf {bind def} def
  98.  
  99. % B -- draw bar (TeX rule) of size w by h at currentpoint
  100. % Usage -- w h B
  101. /B
  102. {
  103.   /h exch def
  104.   /w exch def
  105.   gsave
  106.   currentpoint
  107.   newpath
  108.     moveto
  109.     w 1 sub 0 rlineto
  110.     0 h 1 sub rlineto
  111.     w 1 sub neg 0 rlineto
  112.   closepath fill
  113.   grestore
  114. } bdf
  115.  
  116. % BOJ -- beginning of job (EOF ends it and closes TeXdict)
  117. % Usage -- BOJ
  118. /BOJ
  119. {
  120.   72 Resolution div 72 Resolution div scale
  121.   userdict /note known 
  122.   {LETTER}                % MJF mod 
  123.   {LETTER}                % default page format for others
  124.   ifelse
  125. } bdf
  126.  
  127. % BOP -- beginning of page
  128. % Usage -- BOP
  129. /BOP
  130. {
  131.   clear
  132.   Mtrx setmatrix
  133.   25 0 translate % Physical page origin is at (-25,0) from the top left corner
  134. } bdf
  135.  
  136. % ch-fieldname -- extract field from ch-data array (order defined by positions
  137. % in first array argument to macro D)
  138. % Usage -- ch-fieldname
  139. /ch-image  {ch-data 0 get} bdf    % the bitmap hex string image
  140. /ch-xoff   {ch-data 1 get} bdf    % pixels from left edge of bitmap to char origin
  141. /ch-yoff   {ch-data 2 get} bdf    % pixels from top edge of bitmap to char origin
  142. /ch-width  {ch-data 3 get} bdf    % bitmap width in pixels
  143. /ch-height {ch-data 4 get} bdf  % bitmap height in pixels
  144. /ch-tfmw   {ch-data 5 get} bdf    % pixels to next character (precise flt value)
  145.  
  146. % CharBuilder -- image one character
  147. % Usage -- fontdict ch CharBuilder
  148. /CharBuilder
  149. {
  150.   /ch-code exch def        % save the char code
  151.   /font-dict exch def        % and the font dict.
  152.   /ch-data font-dict /BitMaps get
  153.     ch-code get def        % get the bitmap descriptor for char
  154.   ch-data null eq not        % show character if entry is not empty
  155.   {
  156.     ch-tfmw                0
  157.     ch-xoff neg            ch-yoff ch-height sub
  158.     ch-width ch-xoff sub    ch-yoff
  159.     setcachedevice
  160.     0 0 SNAP translate
  161.     ch-width ch-height true [ 1 0 0 -1 ch-xoff ch-yoff ]
  162.     {ch-image} imagemask
  163.   } if
  164. } bdf
  165.  
  166.  
  167. % D -- define new character in current font
  168. % Usage -- [<bitmap> xoff yoff pixwid pixht tfmpixwid] charnum D
  169. /D
  170. {
  171.   /ch-code exch def
  172.   /ch-data exch def
  173.   currentfont /BitMaps get ch-code ch-data put
  174.   currentfont /Encoding get ch-code dup 3 string cvs cvn put
  175. } bdf
  176.  
  177. % EOJ -- end of job
  178. % Usage -- EOJ
  179. /EOJ
  180. {
  181.   end                % matches begin issued before BOJ
  182. } bdf
  183.  
  184. % EOP -- end of page
  185. % Usage -- ncopies EOP
  186. /EOP
  187. {
  188. /#copies exch def
  189. showpage
  190. } bdf
  191.  
  192. % LANDSCAPE -- landscape format page (11inH x 8.5inV)
  193. % Usage -- LANDSCAPE
  194. /LANDSCAPE
  195. {
  196.   letter initmatrix
  197.   72 Resolution div dup scale
  198.   0 3300 translate
  199.   -90 rotate
  200.   0 -750 translate
  201.   Mtrx currentmatrix pop
  202. } bdf
  203.  
  204. % LANDSCAPE -- landscape format page (11inH x 8.5inV)
  205. % Usage -- LEGAL_LAND
  206. /LEGAL_LAND
  207. {
  208.   legal initmatrix
  209.   72 Resolution div dup scale
  210.   0 4200 translate
  211.   -90 rotate
  212.   0 -750 translate
  213.   Mtrx currentmatrix pop
  214. } bdf
  215.  
  216. % LEGAL -- legal format page (8.5inH x 14inV)
  217. % Usage -- LEGAL
  218. /LEGAL
  219. {
  220.   legal initmatrix
  221.   72 Resolution div dup scale
  222.   0 900 translate
  223.   Mtrx currentmatrix pop
  224. } bdf
  225.  
  226. % LETTER -- letter format page
  227. % Usage -- LETTER
  228. /LETTER
  229. {
  230.   letter initmatrix
  231.   72 Resolution div dup scale
  232.   Mtrx currentmatrix pop
  233. } bdf
  234.  
  235. % M -- moveto
  236. % Usage -- x y M
  237. /M
  238. {
  239.   moveto
  240. } bdf
  241.  
  242. % Mtrx -- permanent storage for page transformation matrix
  243. % Usage -- Mtrx
  244. /Mtrx 6 array def
  245.  
  246. % NF -- define new font
  247. % Usage -- /fontname NF
  248. /NF
  249. {
  250.   /newname exch def
  251.   newname 7 dict def
  252.   newname load
  253.   begin
  254.     /BitMaps 128 array def
  255.     /BuildChar { CharBuilder } def
  256.     /Encoding 128 array def
  257.     0 1 127 { Encoding exch /.notdef put } for
  258.     /FontBBox [ 0 0 1 1 ] def
  259.     /FontMatrix [ 1 0 0 1 0 0 ] def
  260.     /FontType 3 def
  261.   end
  262.   newname newname load definefont pop
  263. } bdf() pop
  264.  
  265. % NOTE -- note format page (increases available virtual memory from 240K
  266. %      to 340K on Apple LaserWriter)
  267. % Usage -- NOTE
  268. /NOTE
  269. {
  270.   note initmatrix
  271.   72 Resolution div dup scale           % set scaling to 1.
  272.   Mtrx currentmatrix pop
  273. } bdf
  274.  
  275. % P -- show string at current point, updating horizontal position to new endpt
  276. % Usage -- (string) P
  277. /P {show} bdf() pop
  278.  
  279. % Q -- draw bar of last size set by B command at specified point
  280. % Usage -- x y Q
  281. /Q {moveto w h B} bdf() pop
  282.  
  283. % R -- move relative right and show string, updating horizontal position to
  284. %      new endpoint
  285. % Usage -- (string) xxx R
  286. /R {0 rmoveto show} bdf() pop
  287.  
  288. % Resolution -- device resolution in dots/inch
  289. % Usage -- Resolution
  290. /Resolution 300 def
  291.  
  292. % S -- move absolute and show string, updating horizontal position to new endpt
  293. % Usage -- (string) xxx yyy S
  294. /S {moveto show} bdf() pop
  295.  
  296. % SF -- set new font at scale nnn (nnn = 1 normally; 2 gives double size chars)
  297. % Usage -- nnn /fontname SF
  298. /SF {findfont exch scalefont setfont} bdf() pop
  299.  
  300. % SNAP -- convert coordinates to integer device coordinates and back again
  301. % Usage -- xxx yyy SNAP (leave xxx' yyy' on stack)
  302. /SNAP {transform 2 {floor 0.5 add exch} repeat itransform} bdf
  303.  
  304. % T -- move absolute horizontally and show string, updating horizontal position
  305. % to new endpt
  306. % Usage -- (string) xxx T
  307. /T {currentpoint exch pop moveto show} bdf() pop
  308.  
  309. end                % TeXdict
  310.